$(function () {

    var html_data = {
        baseConfig: baseConfig,
        sessionid: '',
        sessionid_q: '',
        express_list: []

    };
    var app = new Vue({
        el: '#host_express_html',
        data: html_data,
        methods: {
            choice_express: function (payorder_id, express_id) {
                if (payorder_id) {
                    api.lorder.update_pay_order_express({
                        order_id: payorder_id,
                        express_id: express_id
                    }).then(function (data) {
                        history.go(-1);
                    });
                }

            },
            create_express: function () {
                Magiclamp.mcPrompt("请输入运费模板名称", "模板名称", function (name) {
                    api.lorder.create_express_template({name:name}).then(function (result) {
                        if(result.success){
                            api.lorder.query_express_template_list().then(function (data) {
                                html_data.express_list = data.result.list;
                            });
                        }else{
                            Magiclamp.mcAlert(result.message);
                        }
                    })
                })
            },
            modefy_express: function (express_id, is_modefy) {
                location.href = 'host_express_template_item.html?express_id=' + express_id+"&express_is_modefy="+is_modefy;
            },
            modefy_express_name: function (express) {
                Magiclamp.mcPrompt("请输入运费模板名称", express.name, function (name) {
                    api.lorder.update_express_template({name:name, express_id:express.id}).then(function (result) {
                        if(result.success){
                            api.lorder.query_express_template_list().then(function (data) {
                                html_data.express_list = data.result.list;
                            });
                        }else{
                            Magiclamp.mcAlert("提示",result.message);
                        }
                    })
                }, express.name);
            },
            update_default_express: function (default_express) {
                api.lorder.update_default_express({express_id: default_express}).then(function (data) {

                })
            },
            delete_express: function (express) {
                api.lorder.delete_express({express_id: express.id}).then(function (data) {
                    express.is_active = false;
                })
            },
            page_back: function () {
                baseConfig.page_back();
            }
        }
    });

    html_data.sessionid = GetQueryString('sessionid');
    if (html_data.sessionid) {
        html_data.sessionid_q = "sessionid=" + html_data.sessionid;
        client_storage('sessionid', html_data.sessionid);
    }


    api.lorder.query_express_template_list().then(function (data) {
        html_data.express_list = data.result.list;

    });


});
